<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <script src="./lib/axios.js"></script>
  <title>Document</title>

  <style>
    .content {
      display: flex;
      justify-content: start;
      flex-wrap: wrap;
    }

    .file-load {
      position: relative;
      border: 1.5px solid rgba(112, 112, 112, 0.596);
      border-radius: 5px;
      width: 200px;
      height: 225px;
      padding: 20px;
      box-shadow: 0 0 2px 1px rgba(0, 0, 0, 0.24);
      margin: 10px;
    }

    .double {
      width: 460px;
    }

    .title {
      display: flex;
      justify-content: space-between;
      white-space: nowrap;
    }

    .title>span {
      align-self: flex-end;
      font-size: 14px;
      color: rgba(59, 59, 59, 0.671);
      padding-bottom: 10px;
    }

    .file-bnt {
      padding: 10px 20px;
      border: none;
      border-radius: 6px;
      background: rgb(194, 255, 153);
      box-shadow: 0 0 2px 1px rgba(0, 0, 0, 0.24);
      font-size: 16px;
      color: rgba(58, 58, 58, 0.822);
    }

    .file-bnt-disabled {
      color: rgb(180, 180, 180);
    }

    .upload {
      position: absolute;
      right: 20px;
    }

    .active:hover {
      background: rgba(141, 255, 141, 0.637);
      cursor: pointer;
    }

    .active2:hover {
      color: black;
      cursor: pointer;
    }

    .actived2 {
      color: black;
    }

    .file_inp {
      display: none;
    }

    .file-load .info {
      font-size: 15px;
      color: rgb(173, 173, 173);
      margin-top: 10px;
      border: 1px solid rgba(0, 0, 0, 0.11);
      padding: 8px;
      height: 100px;
      border-radius: 10px;
      max-height: 250px;
      overflow: auto;
    }

    .half {
      width: 220px;
    }

    .preview {
      position: relative;
      display: flex;
      justify-content: space-between;
    }

    .preview .clear {
      position: absolute;
      right: 4px;
      top: 14px;
      width: 24px;
      height: 24px;
      line-height: 24px;
      border-radius: 50%;
      border: none;
      color: rgba(0, 0, 0, 0.568);
      font-size: 20px;
      padding: 0;
      background-color: rgba(150, 150, 150, 0.521);
    }

    .preview .clear:hover {
      background-color: rgba(150, 150, 150, 0.808);
      color: aliceblue;
    }

    .preview>.img {
      border: 1px solid rgba(0, 0, 0, 0.308);
      margin: 10px 0 0 10px;
      flex: 1;
      text-align: center;
      display: flex;
      align-items: center;
      justify-content: center;
      font-size: 24px;
      color: rgb(245, 173, 79);
      background-position: center;
      background-repeat: no-repeat;
      background-size: contain;
    }

    .file-load .info>li {
      padding: 0;
      list-style: none;
      margin: 5px 0;
      display: flex;
      justify-content: space-around;
      align-items: center;
    }

    .file-load .info>li>span {
      white-space: nowrap;
      text-overflow: ellipsis;
      overflow: hidden;
      width: calc(100% - 60px);
    }

    .remove {
      border: none;
      background: none;
      padding: 0;
      font-size: 14px;
      color: rgba(255, 120, 120, 0.822);
      cursor: pointer;
    }

    .remove-disabled {
      color: rgba(87, 86, 86, 0.479);
    }

    .remove-active:hover {
      color: rgb(255, 0, 0);
    }

    .progress {
      width: 90%;
      margin: 50px 5%;
      height: 8px;
      border: 1px solid rgba(0, 0, 0, 0.192);
      border-radius: 0;
      transition: all 0.3s;
    }

    /* 进度条改样式 */
    /* 表示总长度背景色 */
    progress::-webkit-progress-bar {
      background-color: rgb(243, 243, 243);
    }

    /* 表示已完成进度背景色 */
    progress::-webkit-progress-value {
      background: lightskyblue;
    }


    :disabled {
      background: transparent;
    }

    ::-webkit-scrollbar {
      display: none;
    }
  </style>
</head>

<body>

  <script src="./js/public.js"></script>

  <!-- form表单提交 -->
  <form action="http://127.0.0.1:3000/upload_form" method="post" enctype="multipart/form-data" target="frameName">
    <input type="file" name="files" class="file-bnt select active" multiple>
    <input type="text" name="fqm" style="display: none;">
    <input type="submit" value="submit" class="file-bnt active" style="margin-left: 10px;">
  </form>
  <iframe src="" frameborder="0" name="frameName" style="display: none;"></iframe>

  <hr style="margin: 20px">

  <div class="content">
    <!-- form-data  -----小文件不分割(适合上传图片,文档等等等) -->
    <div class="file-load">
      <div class="title">
        <h2>form-data</h2>
        <span class="formdata-size">0MB</span>
      </div> <!-- 限制格式1：直接在input上加accept表示只接受某些格式, 也可以通过js来限制格式 -->
      <!-- <input type="file" id="file_inp" accept=".png" multiple> -->
      <input type="file" class="file_inp formdata-files" multiple>
      <button class="file-bnt select active formdata-select">select</button>
      <button class="file-bnt upload active formdata-upload">upload</button>
      <div class="info formdata-info">
        请选择文件上传(小于1GB, 50个以内), 长按我清空文件列表
      </div>
    </div>

    <script src="./js/form-data.js"></script>


    <!-- base64 -->
    <div class="file-load">
      <div class="title">
        <h2>base64</h2>
        <span class="base64-size">0MB</span>
      </div>
      <input type="file" class="file_inp base64-files" multiple>
      <button class="file-bnt select active base64-select">select</button>
      <button class="file-bnt upload active base64-upload" type="button">upload</button>
      <div class="info base64-info">
        请选择png, jpeg, jpg, gif, icon, tiff, jfif, webp格式文件上传图片(小于200MB, 50个以内), 长按我清空文件列表
      </div>
    </div>

    <script src="./js/base64.js"></script>


    <!-- 预览base64 -->

    <div class="file-load double">
      <div class="title">
        <h2>preview(base64)</h2>
        <span class="preview-size">0MB</span>
      </div>
      <input type="file" class="file_inp preview-files" multiple>
      <button class="file-bnt select active preview-select">select</button>
      <button class="file-bnt upload active preview-upload">upload</button>
      <div class="preview">
        <div class="info preview-info half">
          请选择png, jpeg, jpg, gif, icon, tiff, jfif, webp格式文件上传图片(小于200MB, 50个以内), 长按我清空文件列表
        </div>
        <button class="clear">×</button>
        <div class="img">
          preview
        </div>
      </div>
    </div>

    <script src="./js/preview(base64).js"></script>



    <!-- 进度显示  formdata 多文件 一个请求, 全部单进度 -->
    <div class="file-load double">
      <div class="title">
        <h2>progress-display(single)</h2>
        <span class="progress-size">0MB
        </span>
      </div> <!-- 限制格式1：直接在input上加accept表示只接受某些格式, 也可以通过js来限制格式 -->
      <!-- <input type="file" id="file_inp" accept=".png" multiple> -->
      <input type="file" class="file_inp progress-files" multiple>
      <button class="file-bnt select active progress-select">select</button>
      <button class="file-bnt upload active progress-upload">upload</button>
      <div class="info progress-info">
        请选择文件上传(小于1GB, 50个以内), 长按我清空文件列表
      </div>
    </div>

    <script src="./js/progressDisplay(form-data).js"></script>


    <!-- 上传文件大了,就会出问题 -->

    <!-- 进度显示  formdata 多文件 多请求, 多进度 -->
    <div class="file-load double">
      <div class="title">
        <h2>progress-display(multipart)</h2>
        <span class="progress2-size">0MB
        </span>
      </div> <!-- 限制格式1：直接在input上加accept表示只接受某些格式, 也可以通过js来限制格式 -->
      <!-- <input type="file" id="file_inp" accept=".png" multiple> -->
      <input type="file" class="file_inp progress2-files" multiple>
      <button class="file-bnt select active progress2-select">select</button>
      <button class="file-bnt upload active progress2-upload">upload</button>
      <div class="info progress2-info">
        请选择文件上传(小于1GB, 50个以内), 长按我清空文件列表
      </div>
    </div>

    <script src="./js/progress2.js"></script>


    <!-- 拖拽上传 -->
    <div class="file-load double">
      <div class="title">
        <h2>drag-upload</h2>
        <span class="drag-size">0MB
        </span>
      </div> <!-- 限制格式1：直接在input上加accept表示只接受某些格式, 也可以通过js来限制格式 -->
      <!-- <input type="file" id="file_inp" accept=".png" multiple> -->
      <input type="file" class="file_inp drag-files" multiple>
      <button class="file-bnt select active drag-select">select</button>
      <button class="file-bnt upload active drag-upload">upload</button>
      <div class="info drag-info">
        请选择文件上传(小于1GB, 50个以内), 可拖拽上传, 长按我清空文件列表
      </div>
    </div>

    <script src="js/drag-upload.js"></script>


    <!-- 切片上传 -->
    <div class="file-load double">
      <div class="title">
        <h2>chunk-upload</h2>
        <span class="chunk-size">0MB
        </span>
      </div> <!-- 限制格式1：直接在input上加accept表示只接受某些格式, 也可以通过js来限制格式 -->
      <!-- <input type="file" id="file_inp" accept=".png" multiple> -->
      <input type="file" class="file_inp chunk-files" multiple>
      <button class="file-bnt select active chunk-select">select</button>
      <button class="file-bnt upload active chunk-upload">upload</button>
      <div class="info chunk-info">
        请选择文件上传, 可拖拽上传, 长按我清空文件列表
      </div>
    </div>

    <script src="js/chunk-upload.js"></script>



  </div>

</body>

</html>

<!-- 前端刷新的原因找到了, 是因为后端nodejs的promise异步响应post请求导致的,如果是同步响应似乎返回一样的数据也不会出问题 -->